/* 增强的聊天界面样式 */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.02) 0%, rgba(255, 255, 255, 0.01) 100%);
}

.chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.06) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  border-radius: 20px 20px 0 0;
}

.chat-title-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-status {
  display: flex;
  align-items: center;
  gap: 16px;
}

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(76, 175, 80, 0.15);
  border-radius: 12px;
  border: 1px solid rgba(76, 175, 80, 0.3);
}

.connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4CAF50;
  animation: pulse-connection 2s infinite;
}

.connection-dot.online {
  background: #4CAF50;
  box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.connection-dot.offline {
  background: #f44336;
  box-shadow: 0 0 8px rgba(244, 67, 54, 0.6);
}

@keyframes pulse-connection {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.3);
  }
}

.connection-text {
  font-size: 11px;
  color: #4CAF50;
  font-weight: 500;
}

.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: rgba(0, 123, 255, 0.8);
  font-weight: 500;
}

.typing-dots {
  display: flex;
  gap: 2px;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  background: rgba(0, 123, 255, 0.8);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typing-bounce {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

.chat-actions {
  display: flex;
  gap: 8px;
}

.action-btn {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  gap: 6px;
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%);
}

.clear-btn {
  background: linear-gradient(135deg, #ff4444 0%, #cc3333 100%);
  border-color: rgba(255, 68, 68, 0.3);
}

.clear-btn:hover {
  box-shadow: 0 4px 15px rgba(255, 68, 68, 0.4);
}

.chat-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 0px; /* 为顶部固定的输入框留出空间 */
}

/* 消息容器样式 */
.message-container {
  display: flex;
  flex-direction: column;
  max-width: 100%;
  margin-bottom: 8px;
}

.message-content-wrapper {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* agent消息靠左对齐 */
.agent-message {
  align-self: flex-start;
  margin-left: 0;
  width: 100%;
  display: flex;
  justify-content: flex-start;
}

/* 用户消息靠右对齐 */
.user-message {
  align-self: flex-end;
  width: 100%;
  display: flex;
  justify-content: flex-end;
}

.user-message .message-content-wrapper {
  flex-direction: row-reverse;
}

.user-message .message-name {
  text-align: right;
}

/* 系统消息居中对齐 */
.system-message {
  align-self: center;
  max-width: 90%;
}

/* 头像样式 */
.avatar-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 40px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.user-avatar {
  background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
}

.agent-avatar {
  background: linear-gradient(135deg, #5E5CE6 0%, #3634A3 100%);
}

.system-avatar {
  background: linear-gradient(135deg, #FF9500 0%, #FF5E3A 100%);
}

.message-name {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  margin-top: 4px;
  text-align: center;
}

/* 消息气泡样式 */
.message-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 70vw;
  word-break: break-word;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: relative;
  font-size: 14px;
  line-height: 1.5;
}

.user-bubble {
  background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.agent-bubble {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  color: white;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.system-bubble {
  background: linear-gradient(135deg, rgba(255, 149, 0, 0.2) 0%, rgba(255, 94, 58, 0.1) 100%);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 149, 0, 0.3);
  text-align: center;
  max-width: 80%;
  align-self: center;
}

/* 思考气泡样式 */
.think-bubble {
  background: linear-gradient(135deg, rgba(94, 92, 230, 0.2) 0%, rgba(54, 52, 163, 0.1) 100%);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(94, 92, 230, 0.3);
}

.think-label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: rgba(94, 92, 230, 0.9);
}

.think-text {
  font-style: italic;
  opacity: 0.8;
}

/* 消息时间样式 */
.message-time {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
  margin: 4px 0;
  text-align: center;
}

/* 系统消息容器样式 */
.system-message-container {
  display: flex;
  justify-content: center;
  margin: 8px 0;
}

/* 系统通知样式 - 类似时间消息但更突出 */
.system-notification {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  background: linear-gradient(135deg, rgba(255, 149, 0, 0.15) 0%, rgba(255, 94, 58, 0.1) 100%);
  border: 1px solid rgba(255, 149, 0, 0.3);
  border-radius: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 8px rgba(255, 149, 0, 0.1);
}

.system-icon {
  font-size: 12px;
  opacity: 0.9;
}

.system-text {
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* 移动端适配 */
@media (max-width: 480px) {
  .message-bubble {
    max-width: 75vw;
    padding: 10px 14px;
    font-size: 13px;
  }
  
  .avatar {
    width: 32px;
    height: 32px;
    font-size: 16px;
  }
  
  .message-name {
    font-size: 9px;
  }
  
  .message-content-wrapper {
    gap: 8px;
  }
}

.welcome-message {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 20px;
}

.welcome-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #5E5CE6 0%, #3634A3 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 2px 10px rgba(94, 92, 230, 0.4);
}

.welcome-content {
  background: linear-gradient(135deg, rgba(0, 123, 255, 0.15) 0%, rgba(0, 123, 255, 0.08) 100%);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(0, 123, 255, 0.2);
  padding: 16px;
  max-width: 80%;
  backdrop-filter: blur(10px);
}

.welcome-content h3 {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  margin: 0 0 8px 0;
}

.welcome-content p {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0;
  line-height: 1.5;
}

@media (max-width: 480px) {
  .welcome-content {
    padding: 14px;
    max-width: 85%;
  }
  
  .welcome-content h3 {
    font-size: 15px;
  }
  
  .welcome-content p {
    font-size: 13px;
  }
  
  .welcome-avatar {
    width: 36px;
    height: 36px;
    font-size: 20px;
  }
}

.chat-input-container {
  padding: 12px 16px 16px;
  background: linear-gradient(135deg, rgba(20, 20, 30, 0.9) 0%, rgba(10, 10, 20, 0.95) 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  position: fixed;
  top: auto; /* 调整位置，在聊天标题下方 */
  left: 0;
  bottom: 0;
  right: 0;
  z-index: 10;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.chat-input-area {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}

.input-wrapper {
  flex: 1;
  position: relative;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  transition: all 0.3s ease;
  overflow: hidden;
}

.input-wrapper:focus-within {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(0, 123, 255, 0.6);
  box-shadow: 0 0 20px rgba(0, 123, 255, 0.3);
}

.message-textarea {
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 16px 8px;
  font-size: 15px;
  color: #ffffff;
  outline: none;
  resize: none;
  font-family: inherit;
  line-height: 1.4;
  max-height: 120px;
  min-height: 24px;
  overflow-y: auto;
}

.message-textarea::placeholder {
  color: rgba(255, 255, 255, 0.5);
}

.input-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 16px 8px;
}

.input-counter {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 500;
}

.send-btn {
  background: linear-gradient(135deg, #007AFF 0%, #0056CC 100%);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px; /* 固定尺寸 */
  height: 48px; /* 固定尺寸 */
  flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.4);
}

.send-btn:active {
  transform: translateY(0) scale(0.95);
}

.send-btn:disabled {
  background: rgba(255, 255, 255, 0.1);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.5;
}

.quick-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}

.quick-actions::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Edge */
}

.quick-btn {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%);
  color: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  white-space: nowrap;
  flex-shrink: 0;
}

.quick-btn:hover {
  background: linear-gradient(135deg, rgba(0, 123, 255, 0.2) 0%, rgba(0, 123, 255, 0.1) 100%);
  border-color: rgba(0, 123, 255, 0.4);
  transform: translateY(-1px);
}

/* 移动端适配 */
@media (max-width: 480px) {
  .chat-input-container {
    padding: 10px 12px 12px;
  }
  
  .chat-input-area {
    gap: 8px;
  }
  
  .message-textarea {
    padding: 10px 14px 6px;
    font-size: 14px;
  }
  
  .send-btn {
    width: 36px;
    height: 36px;
  }
  
  .quick-btn {
    padding: 5px 10px;
    font-size: 11px;
  }
}

/* 增强的底部导航样式 */
.bottom-navigation {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.06) 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(20px);
  margin: 0 8px 8px 8px;
  border-radius: 0 0 20px 20px;
  padding: 8px 0 12px;
}

.nav-container {
  display: flex;
  align-items: center;
  justify-content: space-around;
  position: relative;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  opacity: 0.6;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 8px 16px;
  border-radius: 16px;
  position: relative;
  background: none;
  border: none;
  color: inherit;
  font-family: inherit;
  min-width: 80px;
}

.nav-item[aria-selected="true"] {
  opacity: 1;
  background: rgba(0, 123, 255, 0.15);
  box-shadow: 0 0 20px rgba(0, 123, 255, 0.3);
}

.nav-item:active {
  transform: scale(0.95);
}

.nav-icon-wrapper {
  position: relative;
  margin-bottom: 4px;
}

.nav-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.3));
  transition: all 0.3s ease;
}

.nav-item[aria-selected="true"] .nav-icon {
  filter: drop-shadow(0 0 12px rgba(0, 123, 255, 0.6));
  transform: scale(1.1);
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff4444;
  color: white;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(255, 68, 68, 0.4);
}

.nav-text {
  font-size: 11px;
  color: #ffffff;
  font-weight: 500;
  text-align: center;
}

.nav-indicator {
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #007AFF, #0056CC);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.nav-item[aria-selected="true"] .nav-indicator {
  width: 60%;
}

/* 增强的麦克风按钮样式 */
.mic-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.mic-button {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #FF3B30 0%, #FF2D55 100%);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 25px rgba(255, 59, 48, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: visible;
  border: 2px solid rgba(255, 255, 255, 0.3);
  font-family: inherit;
  color: inherit;
}

.mic-icon-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-icon {
  font-size: 24px;
  color: white;
  transition: all 0.3s ease;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
}

.mic-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  opacity: 0;
  animation: mic-pulse 2s infinite;
}

@keyframes mic-pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

.mic-status-text {
  font-size: 9px;
  color: white;
  font-weight: 500;
  margin-top: 2px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.mic-button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 30px rgba(255, 59, 48, 0.5);
}

.mic-button:active,
.mic-button.recording {
  transform: scale(0.9);
  background: linear-gradient(135deg, #FF2D55 0%, #FF1744 100%);
  box-shadow: 0 4px 20px rgba(255, 59, 48, 0.6);
}

.mic-button.recording .mic-icon {
  animation: mic-recording 1.5s infinite;
}

@keyframes mic-recording {
  0% {
    transform: scale(1);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
  }
  50% {
    transform: scale(1.1);
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.8));
  }
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.5));
  }
}

.mic-waves {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.wave {
  position: absolute;
  width: 64px;
  height: 64px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  opacity: 0;
}

.mic-button.recording ~ .mic-waves .wave {
  animation: wave-expand 2s infinite;
}

.wave-1 { animation-delay: 0s; }
.wave-2 { animation-delay: 0.5s; }
.wave-3 { animation-delay: 1s; }

@keyframes wave-expand {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }
}

/* 响应式调整 */
@media (max-width: 375px) {
  .chat-header {
    padding: 12px 16px;
  }
  
  .chat-input-container {
    padding: 12px 16px 16px;
  }
  
  .mic-button {
    width: 56px;
    height: 56px;
  }
  
  .mic-icon {
    font-size: 20px;
  }
  
  .nav-item {
    min-width: 70px;
    padding: 6px 12px;
  }
  
  .nav-icon {
    font-size: 20px;
  }
}

/* 暗色主题适配 */
@media (prefers-color-scheme: dark) {
  .connection-status {
    background: rgba(76, 175, 80, 0.2);
  }
  
  .welcome-message {
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.15) 0%, rgba(0, 123, 255, 0.08) 100%);
  }
}